The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section.
The Extensible Markup Language (XML) is the standard for data and documents that is finding wide acceptance in the computer industry. XML describes and provides structure to a body of data, such as a file or data packet. The XML standard provides for tags that delimit sections of XML documents referred to as XML elements.
Information about the structure of specific types of XML documents may be specified in documents referred to as “XML schemas”. For example, the XML schema for a particular type of XML document may specify the names for the elements contained in that type of XML document, the hierarchical relationship between the elements contained in that type of XML document, and the type of values contained in that particular type of XML document. Standards governing XML schemas include XML Schema, Part 0, Part 1, Part 2, W3C Recommendation, 2 May 2001, the contents of which are incorporated herein by reference, XML Schema Part 1: Structures, Second Edition, W3C Recommendation 28 October. 2004, the contents of which are incorporated herein by reference, and XML Schema Part 2: Datatypes Second Edition, W3C Recommendation 28 October 28, 2004, the contents of which incorporated herein by reference.
XML Storage Mechanisms
Various types of storage mechanisms are used to store an XML document. One type of storage mechanism stores an XML document as a text file in a file system.
Another type of storage mechanism uses object-relational database systems that are enhanced to store and process queries for collections of XML documents. Furthermore, these object-relational database systems can store and manage XML documents as instances of XML schemas. To store and manage the XML documents in a database system, database representations, defined in terms of database data types handled by the database system, are used to represent XML documents.
For example, a database representation of an entire XML document may be a CLOB (binary large object), or maybe one or more tables whose columns store the components of an XML document in one or more rows. A database representation may be a hierarchy of objects in an object-relational database; each object is an instance of an object class and stores one or more elements of an XML document. The object class defines, for example, the structure corresponding to an element, and includes references or pointers to objects representing the immediate descendants of the element.
XML Date-Time Types
XML standards define data types, referred to herein as XML data types. Among these data types are primitive data types for representing dates and/or times, referred to herein as XML date-time types. Examples of XML date-time types include the XML primitive data types “dateTime”, “date”, “time”, and “gYearMonth”. XML standards are very flexible and permit instance values to have optional properties. For example, XML standards permit the ‘dateTime’ type instance to have an arbitrary level of precision, or to have a time Zone property, i.e. to be “with time-zone”.
In a database system, database types such as American National Standards Institute (“ANSI”) SQL types DATE, TIMESTAMP, and TIMESTAMP WITH TIMEZONE are used as a database representation of an XML date-time type. Database types for date and/or time values are referred to herein database date-time types. The present invention is not limited to any data type of any particular standard for database languages.
For database date-time types, optional properties may be declared. For example, TIMESTAMP(5) declares a timestamp with a level of precision of 5 (i.e. seconds to five decimal places).
Database date-time types are used for database representations of XML date-time types. When using a database date-time type as a database representation of a XML date-time type, a decision is made as to what extent the full range of options of the XML date-time type is to be supported by a database date-time type. The decision needs to strike a balance between supporting a wider range of options and using more database system resources to support the range of options. For example, the time zone property of the XML dateTime type may be supported by the TIMESTAMP WITH TIME ZONE database type. However, this database type requires more storage space than other alternatives, such as TIMESTAMP. If XML documents stored in a database system do not include dataTime instances with time zone, then database system resources are wasted to support a feature that is not ever used. Similarly, a level of precision of 5 can be supported by using a database type of TIMESTAMP(5). However, many dataTime instances in XML documents stored in a database system may not have this level of precision.
Unfortunately, user requirements vary. To handle this, XML date-time types are by default represented by a general all-purpose database representation that can handle a wide range of user requirements, but not necessarily all of the user requirements. As a result, either resources are wasted to support a range of options that are seldom if ever used, or user requirements for XML date-time types are not supported in some situations.
Based on the forgoing, a mechanism is needed that allows use of database date-time types as database representations of XML date-time types to be tailored to particular user needs and/or circumstances.